# -*- encoding=utf8 -*-
__author__ = "Administrator"

import random
from airtest.core.api import *
from airtest.cli.parser import cli_setup


if not cli_setup():
    auto_setup(__file__, logdir=True, devices=["android://127.0.0.1:5037/c9a55ee3?cap_method=ADBCAP&touch_method=MAXTOUCH&",]) # xiaomi
#     auto_setup(__file__, logdir=True, devices=["android://127.0.0.1:5037/472eedaa?cap_method=ADBCAP&touch_method=MAXTOUCH&",]) # oppo


# script content
print("start...")

# 获取设备屏幕尺寸
width, height = device().get_current_resolution()
# width, height = 1080, 2340 

# 定义滑动参数
start_x = width * 0.5  # 屏幕中间x坐标
start_y = height * 0.8  # 滑动起始y坐标
end_y = height * 0.2    # 滑动结束y坐标
duration = 0.5         # 滑动持续时间
times = 500
print(start_x,start_y)

# 循环上滑50次
for i in range(times):
    print(f"正在执行第 {i+1} 次上滑")
    swipe((start_x, start_y), (start_x, end_y), duration=duration)
#     poco("android:id/content").swipe("up")
    # 每次滑动后随机等待1-3秒，模拟真实用户操作
    sleep(random.uniform(30, 33))

keyevent('power')    

# generate html report
# from airtest.report.report import simple_report
# simple_report(__file__, logpath=True)